<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <body>
        <ui:composition template="../templates/default3.xhtml">  
            <ui:define name="content">
                <h:form binding="#{salesInquiryManagerBean.loadInquiriesPage}">


                    <p:panel header="Inquiries" id="inquiriesPanel">
                        <h:outputText rendered="#{!userSessionManagerBean.viewCustomerInquiries}" id="output" value="#{userSessionManagerBean.selectedLead.company} 
                                      has #{salesInquiryManagerBean.inquiriesCount} inquiries." />
                        <h:outputText rendered="#{userSessionManagerBean.viewCustomerInquiries}" id="output2" value="#{userSessionManagerBean.customer.company} 
                                      has #{salesInquiryManagerBean.inquiriesCount} inquiries." />
                        <hr />
                        <p:dataTable id="inquiries" var="inquiry" value="#{salesInquiryManagerBean.inquiries}" paginator="false" 
                                     selectionMode="single" rowSelectListener="#{salesInquiryManagerBean.onRowSelect}"
                                     emptyMessage="No inquiries found with given criteria."
                                     selection="#{salesInquiryManagerBean.selectedInquiry}">
                            <p:column filterBy="#{inquiry.id}" headerText="Id" filterMatchMode="contains">  
                                <h:outputText value="#{inquiry.id}" />  
                            </p:column> 
                            <p:column headerText="Inquiry Date"> 
                                <h:outputText value="#{inquiry.inquiryDate}">  
                                    <f:convertDateTime pattern="dd-MM-yyyy hh:mm a" timeZone="#{defaultManagerBean.tz}" />
                                </h:outputText>
                            </p:column>
                            <p:column headerText="Status">
                                <h:outputText value="#{inquiry.status}" />  
                            </p:column>
                        </p:dataTable>
                        <table class="panel">
                            <tr>
                                <td class="btn">
                                    <p:commandButton value="Add Inquiry" actionListener="#{salesInquiryManagerBean.addInquiry}" ajax="true"/>
                                    &nbsp;&nbsp;&nbsp;<p:commandButton id="btnGoBackToUpdateX" value="Done" ajax="true"
                                                     actionListener="#{salesInquiryManagerBean.done}" update="addInquiryItemPanel"/>

                                </td>
                            </tr>
                        </table>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>

    </body>
</html>
